package com.imagine.service.impl;

import com.imagine.entity.BaseResult;
import com.imagine.entity.PersonalSecurityAccount;
import com.imagine.mapper.PersonalSecurityAccountMapper;
import com.imagine.service.PersonalSecurityAccountService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by liangyue on 2017/10/2.
 */
@Service
public class PersonalSecurityAccountServiceImpl implements PersonalSecurityAccountService {
    @Autowired
    PersonalSecurityAccountMapper personalSecurityAccountMapper;

    @Override
    public int insertPersonSecurityAccount(PersonalSecurityAccount personalSecurityAccount){
        return personalSecurityAccountMapper.insertPersonalSecurityAccount(personalSecurityAccount);
    }
    @Override
    public  PersonalSecurityAccount getPersonalSecurityAccountById(int pAccountId){
        return personalSecurityAccountMapper.getPersonalSecurityAccountById(pAccountId);
    }

    @Override
    public List<PersonalSecurityAccount> getPersonalSecurityAccountUnchecked(){
        return personalSecurityAccountMapper.getPersonalSecurityAccountUnchecked();
    }
    @Override
    public BaseResult getPersonalSecurityAccountByPIdNumber(String pIdNumber){
        BaseResult result = new BaseResult();
        PersonalSecurityAccount account = personalSecurityAccountMapper.getPersonalSecurityAccountByPIdNumber(pIdNumber);
        result.success(account.getpAccountId());
        return result;
    }

    @Override
    public BaseResult updatepAccountStateByPIdNumber(String pIdNumber, int state){
        BaseResult result = new BaseResult();
        HashMap<String, String> map = new HashMap<>();
        map.put("pAccountId", pIdNumber);
        map.put("newState", String.valueOf(state));
        personalSecurityAccountMapper.updatepAccountStateByPIdNumber(map);
        result.success("成功更改状态");
        return result;
    }


}
